package com.sunjob.mroresumeproject.dao;

import com.sunjob.common.domain.mroresume.CKParts;
import com.sunjob.common.domain.mroresume.RPParts;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository//声明持久层
public interface RPPartsMapper {
    @Select("select count(*) from rp_partsresume where statues=1 ")
    int querycount();

    @Select("select * from rp_partsresume where statues=1 limit #{pages},#{size}  ")
    List<RPParts> queryRPparts(int pages, int size);

    @Select("select * from rp_partsresume where repairid=#{repairid} and statues=1")
    @Results({
            @Result(property = "repairid",column = "repairid"),
            @Result(property = "partstypes",column = "partstypes"),
            @Result(property = "management",column = "management"),
            @Result(property = "partsinitial",column = "partsinitial"),
            @Result(property = "partsend",column = "partsend"),
            @Result(property = "failreason",column = "failreason"),
            @Result(property = "money",column = "money"),
            @Result(property = "starttime",column = "starttime"),
            @Result(property = "endtime",column = "endtime"),
            @Result(property = "statues",column = "statues"),
    })
    List<RPParts> queryCKparts2(String repairid);



    @Insert("insert into rp_partsresume values(#{repairid},#{RPcontent},#{partstypes},#{management},#{partsinitial},#{partsend},#{failreason},#{money},#{starttime},#{endtime},#{statues})")
    void insertRPparts();

    @Select("select * from rp_partsresume where statues=1")
    @Results({
            @Result(property = "repairid",column = "repairid"),
            @Result(property = "RPcontent",column = "RPcontent"),
            @Result(property = "partstypes",column = "partstypes"),
            @Result(property = "management",column = "management"),
            @Result(property = "partsinitial",column = "partsinitial"),
            @Result(property = "partsend",column = "partsend"),
            @Result(property = "failreason",column = "failreason"),
            @Result(property = "money",column = "money"),
            @Result(property = "starttime",column = "starttime"),
            @Result(property = "endtime",column = "endtime"),
            @Result(property = "statues",column = "statues"),
    })
    List<RPParts> queryRPparts5();

    @Select("select * from rp_partsresume where repairid=#{repairid} and statues=1")
    @Results({
            @Result(property = "repairid",column = "repairid"),
            @Result(property = "partstypes",column = "partstypes"),
            @Result(property = "management",column = "management"),
            @Result(property = "partsinitial",column = "partsinitial"),
            @Result(property = "partsend",column = "partsend"),
            @Result(property = "failreason",column = "failreason"),
            @Result(property = "money",column = "money"),
            @Result(property = "starttime",column = "starttime"),
            @Result(property = "endtime",column = "endtime"),
            @Result(property = "statues",column = "statues"),
    })
    List<RPParts> queryRPpartsone(Long repairid);

    @Update("update rp_partsresume set RPcontent=#{RPcontent},partstypes=#{partstypes},management=#{management},partsinitial=#{partsinitial},partsend=#{partsend},failreason=#{failreason},money=#{money},starttime=#{starttime},endtime=#{endtime} where repairid=#{repairid}")
    void updateRPparts(String repairid, String rPcontent, String partstypes, String management, String partsinitial, String partsend, String failreason, String money, String starttime, String endtime);

    @Update("update rp_partsresume set statues=0 where repairid=#{repairid}")
    void deleteRPparts(String repairid);

    @Update("update rp_partsresume set statues=0 where repairid=#{s}")
    void deleteRPpartsone(String s);
}
